// import apis from '../../request/apis.js'
var apis = {};
apis.searchApi = "https://api.douban.com/v2/book/search"
//这个语句可以获取应用实例
var app = getApp();

Page({
    data: {
        inputValue: 'javascript',
        books: [],
        offset: 0
    },
    search: function(){
        var _this = this;
        wx.request({
            url: apis.searchApi,
            data: {
                q: _this.data.inputValue,
                start: _this.data.offset
            },
            header: {
                'Content-Type': 'application/json'
            },
            success: function(res){
                _this.setData({
                    books: res.data.books
                });
                console.log(_this.data.books);
            }
        });
    },
    setSelectBookId: function(id){
        app.selectBookId = id;
        this.viewBookDetail();
    },
    onReady: function(){
        
    },
    viewBookDetail: function(e){
        wx.navigateTo({
            url:'../detail/detail?id='+e.currentTarget.dataset.bookid
        });
        console.dir(e);
    },
    getp: function(e){
        this.setData({
            inputValue: e.detail.value
        });
        console.log(this.data.inputValue);
    }
});